<?php


namespace app\api\controller;


use app\api\validate\User;
use app\BaseController;
use app\common\lib\sms\AliSms;
use think\exception\ValidateException;
use think\facade\Cache;

class Sms extends BaseController
{
    public function sendCode()
    {
        $phone = request()->param('phone_number');

        $data = [
            'phone_number' => $phone,
        ];

        try {
            validate(User::class)->scene('send_code')->check($data);
        } catch (ValidateException $exception) {
            return show(2, $exception->getMessage());
        }

        if (!\app\common\business\Sms::sendCode($phone)) {
            return show(2, '短信发送失败');
        }

        return show(1, '短信发送成功');
//        return  json(AliSms::sendSms('15051026117', 1314520));
    }



}